
//
//  TBVistorView.swift
//  新浪微博
//
//  Created by bin on 16/1/23.
//  Copyright © 2016年 XMG. All rights reserved.


import UIKit

protocol TBVistorViewDelegate{
    
    
}

class TBVistorView: UIView {

    @IBOutlet weak var rotateImageView: UIImageView!
    @IBOutlet weak var contentImageView: UIImageView!
    @IBOutlet weak var titleLabel: UILabel!
    @IBOutlet weak var registerBtn: UIButton!
    @IBOutlet weak var loginBtn: UIButton!
    
    
    class func VistorView()->TBVistorView{
        
        return NSBundle.mainBundle().loadNibNamed("TBVistorView", owner: nil, options: nil).last as! TBVistorView
        
    }
    

    @IBAction func register(sender: UIButton) {
        
    }
    
    @IBAction func login(sender: UIButton) {
        
    }
    
    func setupContent(contentImage: String?, title:String? ){
        
        guard let image = contentImage else{

            startAnimation()
            return
        }
        rotateImageView.hidden = true;
        contentImageView.image = UIImage(named: image)
        titleLabel.text = title!
    }
    
    func startAnimation(){
        let ani = CABasicAnimation(keyPath: "transform.rotation")
        ani.toValue = 2.0 * M_PI
        ani.duration = 10
        ani.repeatCount = MAXFLOAT
        ani.removedOnCompletion = false;
        rotateImageView.layer.addAnimation(ani, forKey: nil)
    }
}
